import {
	defineStore
} from "pinia"
import Location from '@/utool/Location';
import overallRequest from "@/utool/http/http.js"
export default defineStore('Location', {
	state: () => ({
		longitude: null,
		latitude: null,
		data: {
			longitude: null,
			latitude: null,
		}
	}),
	actions: {
		// 发送我的位置到服务器
		PushMyLocation: async function() {
			let url = "/user/AddLocation"
			return await overallRequest(url,{
				method:"POST",
				data:this.data
			})
		},
		GetLocation: async function() {
			let result = await Location.GetLocation()
			let {
				longitude,
				latitude
			} = result
			this.longitude = longitude
			this.latitude = latitude
			this.data.longitude = longitude
			this.data.latitude = latitude
		}
	}
})